# Makefile for Calculator Project

# 编译器和工具设置
CXX = g++
GO = go
RM = rm -f

# 编译选项
CXXFLAGS = -fPIC -Wall -std=c++11
LDFLAGS = -shared

# 目标文件
LIB = libcalculator.dylib
OBJ = calculator.o

# 默认目标
all: $(LIB) go-build

# 编译 C++ 源文件为目标文件
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# 生成动态库
$(LIB): $(OBJ)
	$(CXX) $(LDFLAGS) -o $@ $^

# 编译 Go 程序
go-build:
	$(GO) build -o calculator main.go

# 清理编译产物
clean:
	$(RM) $(OBJ) $(LIB) calculator

.PHONY: all go-build clean